"""Import record Pydantic schemas."""

from __future__ import annotations

from typing import Any
from uuid import UUID

from pydantic import Field

from ..schemas.base import ORMBase, TimestampModel


class ImportRecordBase(ORMBase):
    """Base ImportRecord schema."""

    import_batch_id: UUID
    original_data: dict[str, Any]
    normalized_data: dict[str, Any]
    ai_tags: dict[str, Any] | None = None
    ai_extraction_error: str | None = None
    ai_extraction_attempts: int = Field(default=0, ge=0)
    duplicate_candidates: dict[str, Any] | None = None
    confidence: float = Field(default=0.0, ge=0.0, le=1.0)
    status: str = Field(default="pending")
    review_notes: str | None = None
    finalized: bool = Field(default=False)
    finalized_lead_id: int | None = None


class ImportRecordCreate(ImportRecordBase):
    """Schema for creating an import record."""

    pass


class ImportRecordUpdate(ORMBase):
    """Schema for updating an import record."""

    normalized_data: dict[str, Any] | None = None
    ai_tags: dict[str, Any] | None = None
    ai_extraction_error: str | None = None
    ai_extraction_attempts: int | None = Field(None, ge=0)
    duplicate_candidates: dict[str, Any] | None = None
    confidence: float | None = Field(None, ge=0.0, le=1.0)
    status: str | None = None
    review_notes: str | None = None
    finalized: bool | None = None
    finalized_lead_id: int | None = None


class ImportRecordOut(ImportRecordBase, TimestampModel):
    """Schema for import record output."""

    id: int
